<template>
  <!-- 对话框表单 -->
      <el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
          <div
              class="ba-operate-form"
              :class="'ba-' + baTable.form.operate + '-form'"
              :style="'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'"
          >
              <el-form
                  v-if="!baTable.form.loading"
                  ref="formRef"
                  @keyup.enter="baTable.onSubmit(formRef)"
                  :model="baTable.form.items"
                  label-position="right"
                  :label-width="baTable.form.labelWidth + 'px'"
                  :rules="rules"
              >
              <FormItem :label="t('xCorpsq.CORP')" type="string" v-model="baTable.form.items!.CORP" prop="CORP" :input-attr="{ placeholder: t('Please input field', { field: t('xCorpsq.CORP') }),disabled:true }" />
              <FormItem :label="t('xCorpsq.CORPNAME')" type="string" v-model="baTable.form.items!.CORPNAME" prop="CORPNAME" :input-attr="{ placeholder: t('Please input field', { field: t('xCorpsq.CORPNAME') }),disabled:true }" />
              <FormItem :label="t('xCorpsq.ENAME')" type="string" v-model="baTable.form.items!.ENAME" prop="ENAME" :input-attr="{ placeholder: t('Please input field', { field: t('xCorpsq.ENAME') }),disabled:true }" />
              <!-- <FormItem :label="t('xCorpsq.DEPT')" type="string" v-model="baTable.form.items!.DEPT" prop="DEPT" :input-attr="{ placeholder: t('Please input field', { field: t('xCorpsq.DEPT') }) }" /> -->
              <FormItem :label="t('xCorpsq.OP')" type="string" v-model="baTable.form.items!.OP" prop="OP" :input-attr="{ placeholder: t('Please input field', { field: t('xCorpsq.OP') }),disabled:true }" />
              <FormItem :label="t('xCorpsq.OPTIME')" type="datetime" v-model="baTable.form.items!.OPTIME" prop="OPTIME" :input-attr="{ placeholder: t('Please select field', { field: t('xCorpsq.OPTIME') }),disabled:true }" />
              <FormItem :label="t('xCorpsq.SQTYPE')" type="string" v-model="state.SQTYPE" prop="SQTYPE" :input-attr="{ placeholder: t('Please input field', { field: t('xCorpsq.SQTYPE') }),disabled:true }" />
              <FormItem :label="'申请内容'" type="textarea" v-model="state.REMARK" prop="REMARK" :input-attr="{ placeholder: t('Please input field', { field: t('xCorpsq.REMARK') }) }" />
              </el-form>
          </div>
      </el-scrollbar>
      <div style="text-align: right;">
          <el-button type="primary" @click="handleTj"> 提交审批 </el-button>
      </div>
</template>

<script setup lang="ts">
import { reactive, ref, inject } from 'vue'
import { useI18n } from 'vue-i18n'
import type baTableClass from '/@/utils/baTable'
import FormItem from '/@/components/formItem/index.vue'
import { ElForm, ElMessage, FormItemRule } from 'element-plus'
import { buildValidatorData } from '/@/utils/validate'
import createAxios from '/@/utils/axios'


const formRef = ref<InstanceType<typeof ElForm>>()
const baTable = inject('baTable') as baTableClass

const { t } = useI18n()

const rules: Partial<Record<string, FormItemRule[]>> = reactive({
  OPTIME: [buildValidatorData({name: 'date', message: t('Please enter the correct field', { field: t('xCorpsq.OPTIME') })})],
})

const state = reactive({
  OP:'',
  OPTIME:'',
  SQTYPE:'变更',
  REMARK:''
})

const handleTj = ()=>{
  createAxios({
    url:'admin/Corplib/tj',
    data:{
            ...baTable.form.items,
            ...state,
            bizno:baTable.form.items!.BIZNO,
            type:'2',
            TYPE:'2',
        },
        method:'post'
  }).then(()=>{
    ElMessage.success('提交成功')
  })
}

</script>

<style scoped lang="scss"></style>
